<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Sfgrayplot</title>
  </head>
  <body bgcolor="#FFFFFF">
    <center>Scilab Function</center>
    <div align="right">Last update : 03/05/2005</div>
    <p>
      <b>Sfgrayplot</b> - smooth 2D plot of a surface defined by a function using colors
  </p>
    <h3>
      <font color="blue">Calling Sequence</font>
    </h3>
    <dl>
      <dd>
        <tt>Sfgrayplot(x,y,f,&lt;opt_args&gt;)</tt>
      </dd>
      <dd>
        <tt>Sfgrayplot(x,y,f [,strf, rect, nax, zminmax, colminmax, mesh, colout])</tt>
      </dd>
    </dl>
    <h3>
      <font color="blue">Parameters</font>
    </h3>
    <ul>
      <li>
        <tt>
          <b>x,y</b>
        </tt>: real row vectors of size n1 and n2.</li>
      <li>
        <tt>
          <b>f</b>
        </tt>: scilab function (z=f(x,y))</li>
      <li>
        <tt>
          <b>&lt;opt_args&gt;</b>
        </tt>: This represents a sequence of statements <tt>
          <b>key1=value1,
          key2=value2</b>
        </tt>,... where <tt>
          <b>key1</b>
        </tt>,
          <tt>
          <b>key2,...</b>
        </tt> can be one of the following: strf, rect, nax, zminmax, colminmax, mesh, colout
          (see <a href="plot2d.htm">
          <tt>
            <b>plot2d</b>
          </tt>
        </a> for the 3 first and <a href="fec.htm">
          <tt>
            <b>fec</b>
          </tt>
        </a> for the 4 last).</li>
      <li>
        <tt>
          <b>strf,rect,nax</b>
        </tt>: see <a href="plot2d.htm">
          <tt>
            <b>plot2d</b>
          </tt>
        </a>.</li>
      <li>
        <tt>
          <b>zminmax, colminmax, mesh, colout</b>
        </tt>: see <a href="fec.htm">
          <tt>
            <b>fec</b>
          </tt>
        </a>.</li>
    </ul>
    <h3>
      <font color="blue">Description</font>
    </h3>
    <p>
      <tt>
        <b>Sfgrayplot</b>
      </tt> is the same as <tt>
        <b>fgrayplot</b>
      </tt> but the
    plot is smoothed. The function <tt>
        <b>fec</b>
      </tt> is used for smoothing. The
    surface is plotted assuming that it is linear on a set of triangles built
    from the grid (here with n1=5, n2=3):</p>
    <pre>
             _____________
             | /| /| /| /|
             |/_|/_|/_|/_| 
             | /| /| /| /| 
             |/_|/_|/_|/_|</pre>
    <p>The function <a href="colorbar.htm">
        <tt>
          <b>colorbar</b>
        </tt>
      </a> may be used to see the color scale (but
       you must know (or compute) the min and max values).</p>
    <p>Instead of Sfgrayplot, you can use <a href="Sgrayplot.htm">
        <tt>
          <b>Sgrayplot</b>
        </tt>
      </a> and this may be
       a little faster.</p>
    <p>Enter the command <tt>
        <b>Sfgrayplot()</b>
      </tt> to see a demo.</p>
    <h3>
      <font color="blue">Examples</font>
    </h3>
    <pre>
// example #1: plot 4 surfaces
function z=surf1(x,y), z=x*y, endfunction
function z=surf2(x,y), z=x^2-y^2, endfunction
function z=surf3(x,y), z=x^3+y^2, endfunction
function z=surf4(x,y), z=x^2+y^2, endfunction
xbasc()
xset("colormap",[jetcolormap(64);hotcolormap(64)])
ng = get("figure_style") == "new";
x = linspace(-1,1,60);
y = linspace(-1,1,60);
if ng then, drawlater(), end
subplot(2,2,1)
   colorbar(-1,1,[1,64])
   Sfgrayplot(x,y,surf1,strf="041",colminmax=[1,64])
   xtitle("f(x,y) = x*y")
subplot(2,2,2)
   colorbar(-1,1,[65,128])
   Sfgrayplot(x,y,surf2,strf="041",colminmax=[65,128])
   xtitle("f(x,y) = x^2-y^2")
subplot(2,2,3)
   colorbar(-1,2,[65,128])
   Sfgrayplot(x,y,surf3,strf="041",colminmax=[65,128])
   xtitle("f(x,y) = x^3+y^2")
subplot(2,2,4)
   colorbar(0,2,[1,64])
   Sfgrayplot(x,y,surf4,strf="041",colminmax=[1,64])
   xtitle("f(x,y) = x^2+y^2")
if ng then, drawnow(), end
xselect()

// example #2: plot surf3 and add some contour lines 
function z=surf3(x,y), z=x^3+y^2, endfunction
xbasc()
x = linspace(-1,1,60);
y = linspace(-1,1,60);
xset("colormap",hotcolormap(128))
ng = get("figure_style") == "new";
if ng then, drawlater(), end
colorbar(-1,2)
Sfgrayplot(x,y,surf3,strf="041")
fcontour2d(x,y,surf3,[-0.1, 0.025, 0.4],style=[1 1 1],strf="000")
xtitle("f(x,y) = x^3+y^2")
if ng then, drawnow(), end
xselect()

// example #3: plot surf3 and use zminmax and colout optional arguments
//             to restrict the plot for -0.5&lt;= z &lt;= 1
function z=surf3(x,y), z=x^3+y^2, endfunction
xbasc()
x = linspace(-1,1,60);
y = linspace(-1,1,60);
xset("colormap",jetcolormap(128))
ng = get("figure_style") == "new";
if ng then, drawlater(), end
zminmax = [-0.5 1]; colors=[32 96];
colorbar(zminmax(1),zminmax(2),colors)
Sfgrayplot(x, y, surf3, strf="041", zminmax=zminmax, colout=[0 0], colminmax=colors)
fcontour2d(x,y,surf3,[-0.5, 1],style=[1 1 1],strf="000")
xtitle("f(x,y) = x^3+y^2, with parts under z = -0.5 and upper z = 1 removed")
if ng then, drawnow(), end
xselect()
 
  </pre>
    <h3>
      <font color="blue">See Also</font>
    </h3>
    <p>
      <a href="fec.htm">
        <tt>
          <b>fec</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="fgrayplot.htm">
        <tt>
          <b>fgrayplot</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="grayplot.htm">
        <tt>
          <b>grayplot</b>
        </tt>
      </a>,&nbsp;&nbsp;<a href="Sgrayplot.htm">
        <tt>
          <b>Sgrayplot</b>
        </tt>
      </a>,&nbsp;&nbsp;</p>
    <h3>
      <font color="blue">Author</font>
    </h3>
    <p>J.Ph.C.  </p>
  </body>
</html>
